package org.example.bookingsystem.client;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class SystemClient {
    private static final Logger log = LoggerFactory.getLogger(SystemClient.class);
    @Autowired
    private RabbitTemplate rabbitTemplate;
    public String queryBank() {
        String msg = "true";
        Object response = rabbitTemplate.convertSendAndReceive(
                "rpc.exchange2", // 交换机
                "request.routing.key2", // 路由键
                msg // 消息
        );
        if(response!=null){
            return (String)response;
        }
        return null;
    }
    public String pay(String msg){
        Object response = rabbitTemplate.convertSendAndReceive(
                "rpc.exchange2", // 交换机
                "request.routing.key2", // 路由键
                msg // 消息
        );
        log.info(response.toString());
        if(response!=null){
            return (String)response;
        }
        return null;
    }

}
